package functions.ems_process_service;

import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;

import com.beans.FormBean;

import coms.Constants;
import frame.HttpHelper;
import frame.InterTest;
import functions.ems_claim.Claim;

public class Psc{
	private org.slf4j.Logger logger = LoggerFactory.getLogger(Psc.class);

	String menuCategoryCode;
	String result;

	FormBean form;

	public org.slf4j.Logger getLogger() {
		return logger;
	}

	public void setLogger(org.slf4j.Logger logger) {
		this.logger = logger;
	}



	public String getMenuCategoryCode() {
		return menuCategoryCode;
	}

	public void setMenuCategoryCode(String menuCategoryCode) {
		this.menuCategoryCode = menuCategoryCode;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}



	public FormBean getForm() {
		return form;
	}

	public void setForm(FormBean form) {
		this.form = form;
	}

		/**
		 *  code 为最末位菜单
		 * @param code
		 * selectFlowParamUrl="/ems-process-service/psc/formproc/pscFormProc/selectFlowParam"
		 */
	     
		public void selectFlowParam(String code) {
			logger.info("---通过菜单编码---获取到表单id等信息 --- start");
			String url =Constants.SELECTF_FLOW_PARAM_URL;
			try {
				if (code == null || code == "") {
					code = menuCategoryCode;
				}
				url = url + "/" + code;
				result = HttpHelper.post("", url);
				logger.info("selectFlowParam --- " + result);
			//	System.out.println("selectFlowParam --- " + result);
				try {
					JSONObject object = new JSONObject(result);
					JSONObject datas = object.getJSONObject("dataResult");
					String formid = datas.getString("formId");
					String procdefId = datas.getString("procdefId");
					String formProcNo = datas.getString("formProcNo");
					String formUrl = datas.getString("formUrl");
					String formSetId = datas.getString("formSetId");
					String procdefKey = datas.getString("procdefKey");

					form = new FormBean(formid, procdefId, formProcNo, formUrl, formSetId, procdefKey);
					logger.info("表单数据： --- " + form.toString());
					//	System.out.println("create form --- " + form.toString());

				} catch (JSONException e) {
					e.printStackTrace();
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	
}
